package com.onpositive.wiki2.whole.model;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.ObjectInputStream;

import com.onpositive.compactdata.CompactLongVector;

public class W {

	public static void main(String[] args) {
		File file = new File("C:/work/content");
		try {
			ObjectInputStream is = new ObjectInputStream(
					new BufferedInputStream(new FileInputStream(new File(file,
							"content.list"))));
			long[] readObject = (long[]) is.readObject();
			CompactLongVector ll = new CompactLongVector();
			for (int a = 0; a < readObject.length; a++) {
				ll.add(readObject[a]);
			}
			ll.trim();
			File q = new File(file, "content.list2");
			ll.store(q);
			ll = new CompactLongVector(q);
			long l0 = System.currentTimeMillis();
			for (int a = 0; a < readObject.length; a++) {
				long l = ll.get(a);
				if (l != readObject[a]) {
					System.out.println("ERrr");
				}
			}
			long l1 = System.currentTimeMillis();
			System.out.println(l1 - l0);
			System.out.println(ll.memUsed() + ":" + ll.size());
			System.out.println(readObject.length * 8);
			System.out.println(ll.memUsed() / ((double) readObject.length * 8));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
